package com.zby.openApi.service.impl.inner;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zby.OpenApiCommon.model.entity.UserEntity;
import com.zby.OpenApiCommon.service.InnerUserService;
import com.zby.openApi.common.ErrorCode;
import com.zby.openApi.dao.UserDao;
import com.zby.openApi.exception.BusinessException;
import org.apache.commons.lang3.StringUtils;
import org.apache.dubbo.config.annotation.DubboService;

import javax.annotation.Resource;

@DubboService
public class InnerUserServiceImpl implements InnerUserService {

    @Resource
    private UserDao userDao;

    @Override
    public UserEntity getInvokeUser(String accessKey) {
        if (StringUtils.isAnyBlank(accessKey)) {
            throw new BusinessException(ErrorCode.PARAMS_ERROR);
        }
        QueryWrapper<UserEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("accesskey", accessKey);
        UserEntity userEntity = userDao.selectOne(queryWrapper);
        return userEntity;
    }
}
